﻿namespace TfsCloudDeploy.Workflow.Tests
{
    using System.Activities;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using TfsCloudDeploy.Workflow.Core.Activities;
    using System.Activities.Statements;

    /// <summary>
    /// Tests to verify the functionality of the InvokeProcessEx activity
    /// </summary>
    [TestClass]
    public class InvokeProcessExTest
    {
        #region Properties

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get;
            set;
        }

        #endregion Properties

        #region Test Methods

        [TestMethod]
        public void InvokeActivityExInWorkflowTest()
        {
            string expectedOutputString = "test";

            var activity = new InvokeProcessEx();
            activity.Arguments = string.Format(" /C echo {0}", expectedOutputString);
            activity.DisplayName = "Run Command Prompt";
            activity.FileName = "cmd.exe";
            activity.HideArguments = false;
            activity.WorkingDirectory = "";
            activity.OutputDataReceived = new ActivityAction<string> { Argument = new DelegateInArgument<string> { Name = "stdOutput" } };

            // Build a tiny workflow to use to run the InvokeActivityEx activity.
            Sequence workflow = new Sequence { Activities = { activity } };
            var workflowInvoker = new WorkflowInvoker(workflow);
            workflowInvoker.Invoke();

            // TODO: Get the standard output and verify it is as expected.
        }

        #endregion Methods

        #region Other

        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //

        #endregion Other
    }
}